package com.wwj.springboot.utils;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author wwj
 */
public class ThreadPollUtil {

    private static final int corePoolSize = Runtime.getRuntime().availableProcessors();

    /**
     * 手动通过 ThreadPoolExecutor 创建线程池
     *
     * corePoolSize用于指定核心线程数量
     * maximumPoolSize指定最大线程数
     * keepAliveTime和TimeUnit指定线程空闲后的最大存活时间
     *
     * 可以根据项目的需要自定义线程池的参数
     */
    public static ThreadPoolExecutor executor  = new ThreadPoolExecutor(corePoolSize, corePoolSize+1, 10L, TimeUnit.SECONDS,
            new LinkedBlockingQueue<Runnable>(1000));



}
